package com.huibao.hulibao.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.huibao.hulibao.R;
import com.huibao.hulibao.entity.LoginEntity;
import com.huibao.hulibao.utils.T;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by lizhaoyong on 2018/5/7.
 */
public class ZhangHaoLvAdapter extends BaseAdapter {
    private List<LoginEntity> mDatas;
    private Context mContext;
    private LayoutInflater mInflater;
    private String loginName;

    public ZhangHaoLvAdapter(List<LoginEntity> datas, Context context,String loginName) {
        this.mDatas = datas;
        this.mContext = context;
        this.loginName = loginName;

        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mDatas.size();
    }

    @Override
    public Object getItem(int position) {
        return mDatas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;

        LoginEntity le = mDatas.get(position);
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_lv_more_zhanghao, parent, false);
            holder = new ViewHolder(convertView);
            // holder.mTextView = (TextView)convertView.findViewById(R.id.tv_title);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }


        // holder.mTextView.setText(mDatas.get(position));
        holder.tv_lv_zhanghao_name.setText(le.Message.LoginName);
        if(loginName.equals(le.Message.LoginName)){
            holder.iv_lv_is_check.setImageResource(R.mipmap.cb_checked);
        }else{
            holder.iv_lv_is_check.setImageResource(R.mipmap.cb_no_check);
        }
        return convertView;
    }

    static class ViewHolder {


        @BindView(R.id.iv_lv_is_check)
        ImageView iv_lv_is_check;
        @BindView(R.id.tv_lv_zhanghao_name)
        TextView tv_lv_zhanghao_name;

        public ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
